package org.davidtrevien.com.imput.omi.panels.center.planning.datenavigation;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;

import layout.TableLayout;

import org.davidtrevien.utils.date.JMonthLabel;

@SuppressWarnings("serial")
public class DateNavigationView
extends JPanel {

	public JButton prevYear;
	public JLabel year;
	public JButton nextYear;
	
	public JButton prevMonth;
	public JMonthLabel month;
	public JButton nextMonth;
	
	public JButton today;
	
	public DateNavigationView() {
		initComponent();
	}

	private void initComponent() {
		double size[][] = new double[][] {
				{TableLayout.FILL,150,10,120,10,100,TableLayout.FILL},
				{TableLayout.FILL}
		};
		TableLayout layout = new TableLayout(size);
		
		setLayout(layout);
		
		this.prevMonth = new JButton("<");
		this.month = new JMonthLabel(JMonthLabel.UNDEFINED);
		this.nextMonth = new JButton(">");
		
		//add(createNav(this.prevMonth, this.month, this.nextMonth), "1,0");
		
		this.prevYear = new JButton("<");
		this.year = new JLabel("2014");
		this.nextYear = new JButton(">");
		
		add(createNav(this.prevYear, this.year, this.nextYear), "3,0");
		
		this.today = new JButton("Aujourd'hui");
		
		add(this.today, "5,0");
	}
	
	protected JPanel createNav(JButton prev, JLabel label, JButton next) {
		JPanel panel = new JPanel();
		
		double size[][] = new double[][] {
				{40,TableLayout.FILL,40},
				{TableLayout.FILL}
		};
		TableLayout layout = new TableLayout(size);
		
		panel.setLayout(layout);

		label.setHorizontalAlignment(JLabel.CENTER);
		
		panel.add(prev, "0,0");
		panel.add(label, "1,0");
		panel.add(next, "2,0");
		
		return panel;
	}
}
